package gui;

import aries.Interface;
import aries.Setting;
import aries.database.Database;
import aries.database.DatabaseConfiguration;
import aries.database.Query;
import aries.database.TableModel;
import aries.database.Where;
import aries.gui.Wizard;
import aries.security.Validation;
import aries.utils.TextUtil;
import aries.utils.Util;
import code.Data;
import code.Koneksi;
import code.Utils;
import dm.SPP;
import dm.Siswa;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;

public class MainMenu extends javax.swing.JFrame {

    public static byte MASTER_PEMBAYARAN = 0;
    public static byte MASTER_SISWA = 1;
    
    private void hideAllPanel() {
        panelDataSPP.setVisible(false);
        panelDataSiswa.setVisible(false);
        panelPengaturan.setVisible(false);
        panelTransaksiSPP.setVisible(false);
        panelUtama.setVisible(false);
    }
    
    private void hideAllPopUp() {
        popupMaster.setVisible(false);
        popupTransaksi.setVisible(false);
    }
    
    private void refreshTable() {
        SPP spp = new SPP();
        Siswa siswa = new Siswa();
        try {
            tbDataSPP.setModel(new TableModel(spp.getField(), spp.getTable().select()));
            tbDataSiswa.setModel(new TableModel(siswa.getField(), siswa.getTable().select()));
            lbTotalSPP.setText("Terdapat "+tbDataSPP.getRowCount()+" data pembayaran.");
            lbTotalDataSiswa.setText("Terdapat "+tbDataSiswa.getRowCount()+" siswa.");
        } catch (Exception ex) {
            //ex.printStackTrace();
        }
    }
    
    private void refreshId() {
        SPP spp = new SPP();
        try {
            txIdSPP.setText(Query.getAutoIncrement(spp.getTable()));
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    }
    
    private void refreshField(byte form) {
        if (form == MASTER_PEMBAYARAN) {
            cbTingkatanSPP.setSelectedIndex(0);
            cbJenisSPP.setSelectedIndex(0);
            txBiayaSPP.setText("");
            ckDicicilSPP.setSelected(false);
        } else if (form == MASTER_SISWA) {
            txNisSiswa.setText("");
            txNamaSiswa.setText("");
            txAlamatSiswa.setText("");
            cbJekelSiswa.setSelectedIndex(0);
            cbTingkatanSiswa.setSelectedIndex(0);
            cbKelasSiswa.setSelectedIndex(0);
            txOrtuSiswa.setText("");
            txAlamatOrtuSiswa.setText("");
            txHpSiswa.setText("");
        }
    }
    
    private void hideEdit() {
        btBayarSPP.setText("Tambah");
        btUbahSPP.setVisible(false);
        tbDataSPP.clearSelection();
    }
    
    private void showEdit() {
        btBayarSPP.setText("Hapus");
        btUbahSPP.setVisible(true);
    }
    
    private void showHome() {
        hideAllPanel();
        panelUtama.setVisible(true);
    }
    
    private void refreshCheckbox() {
        if (cbTingkatanSiswa.getSelectedIndex() != 1 && cbTingkatanSiswa.getSelectedIndex() != 0) {
            cbKelasSiswa.removeAllItems();
            cbKelasSiswa.addItem("-Pilih Salah Satu-");
            Utils.addToCombobox(cbKelasSiswa, Data.getKelas((String) cbTingkatanSiswa.getSelectedItem()));
        }
    }
    
    public MainMenu() {
        try {
            UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel");
        } catch (Exception e) {
            Interface.nativeLook();
        }
        
        initComponents();
        Koneksi k = new Koneksi();
        
        //Initialize
        txIp.setText(Database.getIp());
        txPort.setText(Database.getPort());
        txDbName.setText(Database.getDbName());
        txUsername.setText(Database.getUser());
        txPassword.setText(Database.getPass());
        btUbahSPP.setVisible(false);
        btUbah.setVisible(false);
        panelDataSPP.setVisible(false);
        panelDataSiswa.setVisible(false);
        panelPengaturan.setVisible(false);
        panelTransaksiSPP.setVisible(false);
        refreshTable();
        refreshId();
        
        //Set Textfield effect
        Interface.JTextField(textCariTransaksiSPP, Interface.BLANK_ON_FOCUS);
        Interface.JTextField(txCariSPP, Interface.BLANK_ON_FOCUS);
        Interface.JTextField(txCariDataSiswa, Interface.BLANK_ON_FOCUS);
        
        //Set combobox value
        Utils.addToCombobox(cbTingkatanSPP, Data.getTingkatan());
        Utils.addToCombobox(cbJenisSPP, Data.getJenisPembayaran());
        Utils.addToCombobox(cbTingkatanSiswa, Data.getTingkatan());
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        popupTransaksi = new javax.swing.JPopupMenu();
        itemSPP = new javax.swing.JMenuItem();
        popupMaster = new javax.swing.JPopupMenu();
        itemDataSiswa = new javax.swing.JMenuItem();
        itemDataPembayaran = new javax.swing.JMenuItem();
        buttonTransaksi = new javax.swing.JButton();
        panelUtama = new javax.swing.JPanel();
        labelSelamatDatang = new javax.swing.JLabel();
        buttonMaster = new javax.swing.JButton();
        buttonPengaturan = new javax.swing.JButton();
        buttonHelp = new javax.swing.JButton();
        panelTransaksiSPP = new javax.swing.JPanel();
        labelNisSpp = new javax.swing.JLabel();
        txNisSpp = new javax.swing.JTextField();
        labelNamaSpp = new javax.swing.JLabel();
        labelNamaValueSpp = new javax.swing.JLabel();
        labelKelasSpp = new javax.swing.JLabel();
        labelKelasValueSpp = new javax.swing.JLabel();
        labelTingkatan = new javax.swing.JLabel();
        labelTingkatanValueSpp = new javax.swing.JLabel();
        labelTagihanBelumBayar = new javax.swing.JLabel();
        scrollTagihan = new javax.swing.JScrollPane();
        tbTagihan = new javax.swing.JTable();
        btBayarSpp = new javax.swing.JButton();
        labelJenisTagihanSpp = new javax.swing.JLabel();
        comboJenisTagihanSpp = new javax.swing.JComboBox();
        labelJumlahBayarSpp = new javax.swing.JLabel();
        textJumlahBayarSpp = new javax.swing.JTextField();
        scrollData = new javax.swing.JScrollPane();
        tabelData = new javax.swing.JTable();
        labelTotal = new javax.swing.JLabel();
        textCariTransaksiSPP = new javax.swing.JTextField();
        btUbahSpp = new javax.swing.JButton();
        btBatalSpp = new javax.swing.JButton();
        labelAlamatSpp = new javax.swing.JLabel();
        labelAlamatValueSpp = new javax.swing.JLabel();
        labelJenisKelamin = new javax.swing.JLabel();
        labelJenisKelaminValue = new javax.swing.JLabel();
        panelDataSiswa = new javax.swing.JPanel();
        lbNisSiswa = new javax.swing.JLabel();
        lbNamaSiswa = new javax.swing.JLabel();
        lbAlamatSiswa = new javax.swing.JLabel();
        lbJekelSiswa = new javax.swing.JLabel();
        lbTingkatanSiswa = new javax.swing.JLabel();
        lbKelasSiswa = new javax.swing.JLabel();
        lbOrtuSiswa = new javax.swing.JLabel();
        lbAlamatOrtuSiswa = new javax.swing.JLabel();
        txNisSiswa = new javax.swing.JTextField();
        txNamaSiswa = new javax.swing.JTextField();
        scAlamatSiswa = new javax.swing.JScrollPane();
        txAlamatSiswa = new javax.swing.JTextArea();
        cbJekelSiswa = new javax.swing.JComboBox();
        cbTingkatanSiswa = new javax.swing.JComboBox();
        cbKelasSiswa = new javax.swing.JComboBox();
        txOrtuSiswa = new javax.swing.JTextField();
        scAlamatOrtuSiswa = new javax.swing.JScrollPane();
        txAlamatOrtuSiswa = new javax.swing.JTextArea();
        btTambah = new javax.swing.JButton();
        btUbah = new javax.swing.JButton();
        btBatal = new javax.swing.JButton();
        scDataSiswa = new javax.swing.JScrollPane();
        tbDataSiswa = new javax.swing.JTable();
        lbTotalDataSiswa = new javax.swing.JLabel();
        txCariDataSiswa = new javax.swing.JTextField();
        lbHpSiswa = new javax.swing.JLabel();
        txHpSiswa = new javax.swing.JTextField();
        btExportDataSiswa = new javax.swing.JButton();
        btImportDataSiswa = new javax.swing.JButton();
        panelDataSPP = new javax.swing.JPanel();
        lbJenisSPP = new javax.swing.JLabel();
        cbJenisSPP = new javax.swing.JComboBox();
        lbBiayaSPP = new javax.swing.JLabel();
        txBiayaSPP = new javax.swing.JTextField();
        lbDicicilSPP = new javax.swing.JLabel();
        ckDicicilSPP = new javax.swing.JCheckBox();
        btBatalSPP = new javax.swing.JButton();
        btBayarSPP = new javax.swing.JButton();
        btUbahSPP = new javax.swing.JButton();
        scrollDataSPP = new javax.swing.JScrollPane();
        tbDataSPP = new javax.swing.JTable();
        lbTotalSPP = new javax.swing.JLabel();
        txCariSPP = new javax.swing.JTextField();
        lbTingkatanSPP = new javax.swing.JLabel();
        cbTingkatanSPP = new javax.swing.JComboBox();
        lbIdSPP = new javax.swing.JLabel();
        txIdSPP = new javax.swing.JTextField();
        lbPembayaran = new javax.swing.JLabel();
        panelPengaturan = new javax.swing.JPanel();
        tabPengaturan = new javax.swing.JTabbedPane();
        panelDatabase = new javax.swing.JPanel();
        lbIp = new javax.swing.JLabel();
        lbPort = new javax.swing.JLabel();
        lbDbName = new javax.swing.JLabel();
        lbUsername = new javax.swing.JLabel();
        lbPassword = new javax.swing.JLabel();
        txIp = new javax.swing.JTextField();
        txPort = new javax.swing.JTextField();
        txDbName = new javax.swing.JTextField();
        txUsername = new javax.swing.JTextField();
        txPassword = new javax.swing.JTextField();
        btOkDb = new javax.swing.JButton();
        btBatalDb = new javax.swing.JButton();

        itemSPP.setText("Pembayaran");
        itemSPP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemSPPActionPerformed(evt);
            }
        });
        popupTransaksi.add(itemSPP);

        itemDataSiswa.setText("Data Siswa");
        itemDataSiswa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemDataSiswaActionPerformed(evt);
            }
        });
        popupMaster.add(itemDataSiswa);

        itemDataPembayaran.setText("Pembayaran");
        itemDataPembayaran.setToolTipText("Pembayaran");
        itemDataPembayaran.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemDataPembayaranActionPerformed(evt);
            }
        });
        popupMaster.add(itemDataPembayaran);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Smart SPP | Cara pintar mengatur pembayaran anda");
        setResizable(false);
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });
        addWindowStateListener(new java.awt.event.WindowStateListener() {
            public void windowStateChanged(java.awt.event.WindowEvent evt) {
                formWindowStateChanged(evt);
            }
        });

        buttonTransaksi.setText("Transaksi");
        buttonTransaksi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTransaksiActionPerformed(evt);
            }
        });

        panelUtama.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        labelSelamatDatang.setFont(new java.awt.Font("Tahoma", 0, 24));
        labelSelamatDatang.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/home.png"))); // NOI18N

        javax.swing.GroupLayout panelUtamaLayout = new javax.swing.GroupLayout(panelUtama);
        panelUtama.setLayout(panelUtamaLayout);
        panelUtamaLayout.setHorizontalGroup(
            panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelUtamaLayout.createSequentialGroup()
                .addContainerGap(258, Short.MAX_VALUE)
                .addComponent(labelSelamatDatang, javax.swing.GroupLayout.PREFERRED_SIZE, 765, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelUtamaLayout.setVerticalGroup(
            panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUtamaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelSelamatDatang, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE)
                .addContainerGap())
        );

        buttonMaster.setText("Master");
        buttonMaster.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonMasterActionPerformed(evt);
            }
        });

        buttonPengaturan.setText("Pengaturan");
        buttonPengaturan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonPengaturanActionPerformed(evt);
            }
        });

        buttonHelp.setText("Tentang");
        buttonHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonHelpActionPerformed(evt);
            }
        });

        panelTransaksiSPP.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Transaksi Pembayaran", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        labelNisSpp.setText("NIS:");

        txNisSpp.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txNisSppKeyReleased(evt);
            }
        });

        labelNamaSpp.setText("Nama:");

        labelNamaValueSpp.setText("-");

        labelKelasSpp.setText("Kelas:");

        labelKelasValueSpp.setText("-");

        labelTingkatan.setText("Tingkatan:");

        labelTingkatanValueSpp.setText("-");

        labelTagihanBelumBayar.setText("Tagihan Yang Belum Dibayar:");

        tbTagihan.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Jenis Tagihan", "Jumlah"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        scrollTagihan.setViewportView(tbTagihan);

        btBayarSpp.setText("Bayar");

        labelJenisTagihanSpp.setText("Jenis Tagihan:");

        comboJenisTagihanSpp.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Pilih Salah Satu-" }));

        labelJumlahBayarSpp.setText("Jumlah Bayar:");

        tabelData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        scrollData.setViewportView(tabelData);

        labelTotal.setText("Terdapat x data(s)");

        textCariTransaksiSPP.setFont(new java.awt.Font("Tahoma", 2, 11));
        textCariTransaksiSPP.setForeground(java.awt.Color.gray);
        textCariTransaksiSPP.setText("Cari");

        btUbahSpp.setText("Ubah");

        btBatalSpp.setText("Batal");

        labelAlamatSpp.setText("Alamat:");

        labelAlamatValueSpp.setText("-");

        labelJenisKelamin.setText("Jenis Kelamin:");

        labelJenisKelaminValue.setText("-");

        javax.swing.GroupLayout panelTransaksiSPPLayout = new javax.swing.GroupLayout(panelTransaksiSPP);
        panelTransaksiSPP.setLayout(panelTransaksiSPPLayout);
        panelTransaksiSPPLayout.setHorizontalGroup(
            panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(scrollTagihan, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
                    .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelNisSpp)
                            .addComponent(labelNamaSpp)
                            .addComponent(labelAlamatSpp))
                        .addGap(44, 44, 44)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelAlamatValueSpp)
                            .addComponent(labelNamaValueSpp)
                            .addComponent(txNisSpp, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)))
                    .addComponent(labelTagihanBelumBayar)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelTransaksiSPPLayout.createSequentialGroup()
                        .addComponent(btBatalSpp, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 62, Short.MAX_VALUE)
                        .addComponent(btUbahSpp, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btBayarSpp, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelJenisTagihanSpp)
                            .addComponent(labelJumlahBayarSpp))
                        .addGap(27, 27, 27)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textJumlahBayarSpp, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE)
                            .addComponent(comboJenisTagihanSpp, 0, 247, Short.MAX_VALUE)))
                    .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelKelasSpp)
                            .addComponent(labelTingkatan)
                            .addComponent(labelJenisKelamin))
                        .addGap(14, 14, 14)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelTingkatanValueSpp)
                            .addComponent(labelKelasValueSpp)
                            .addComponent(labelJenisKelaminValue))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                        .addComponent(labelTotal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 382, Short.MAX_VALUE)
                        .addComponent(textCariTransaksiSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(scrollData, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelTransaksiSPPLayout.setVerticalGroup(
            panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelNisSpp)
                    .addComponent(txNisSpp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelTotal)
                    .addComponent(textCariTransaksiSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelTransaksiSPPLayout.createSequentialGroup()
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelNamaSpp)
                            .addComponent(labelNamaValueSpp))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelAlamatSpp)
                            .addComponent(labelAlamatValueSpp))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelJenisKelaminValue)
                            .addComponent(labelJenisKelamin))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelKelasSpp)
                            .addComponent(labelKelasValueSpp))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(labelTingkatanValueSpp)
                            .addComponent(labelTingkatan))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(labelTagihanBelumBayar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(scrollTagihan, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelJenisTagihanSpp)
                            .addComponent(comboJenisTagihanSpp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelJumlahBayarSpp)
                            .addComponent(textJumlahBayarSpp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelTransaksiSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btBayarSpp)
                            .addComponent(btUbahSpp)
                            .addComponent(btBatalSpp)))
                    .addComponent(scrollData, javax.swing.GroupLayout.DEFAULT_SIZE, 363, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelDataSiswa.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Input Data Siswa", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lbNisSiswa.setText("NIS:");

        lbNamaSiswa.setText("Nama:");

        lbAlamatSiswa.setText("Alamat:");

        lbJekelSiswa.setText("Jenis Kelamin:");

        lbTingkatanSiswa.setText("Tingkatan:");

        lbKelasSiswa.setText("Kelas:");

        lbOrtuSiswa.setText("Nama Orang Tua:");

        lbAlamatOrtuSiswa.setText("Alamat Orang Tua:");

        txAlamatSiswa.setColumns(20);
        txAlamatSiswa.setRows(5);
        scAlamatSiswa.setViewportView(txAlamatSiswa);

        cbJekelSiswa.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Pilih Salah Satu-", "Laki - Laki", "Perempuan" }));

        cbTingkatanSiswa.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Pilih Salah Satu-" }));
        cbTingkatanSiswa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTingkatanSiswaActionPerformed(evt);
            }
        });

        cbKelasSiswa.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Pilih Salah Satu-" }));

        txAlamatOrtuSiswa.setColumns(20);
        txAlamatOrtuSiswa.setRows(3);
        scAlamatOrtuSiswa.setViewportView(txAlamatOrtuSiswa);

        btTambah.setText("Tambah");
        btTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTambahActionPerformed(evt);
            }
        });

        btUbah.setText("Ubah");
        btUbah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUbahActionPerformed(evt);
            }
        });

        btBatal.setText("Baru");
        btBatal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBatalActionPerformed(evt);
            }
        });

        tbDataSiswa.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbDataSiswa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbDataSiswaMouseClicked(evt);
            }
        });
        scDataSiswa.setViewportView(tbDataSiswa);

        lbTotalDataSiswa.setText("Terdapat x data(s)");

        txCariDataSiswa.setFont(new java.awt.Font("Tahoma", 2, 11));
        txCariDataSiswa.setForeground(java.awt.Color.gray);
        txCariDataSiswa.setText("Cari");
        txCariDataSiswa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txCariDataSiswaKeyReleased(evt);
            }
        });

        lbHpSiswa.setText("No Handphone:");

        btExportDataSiswa.setText("Export");
        btExportDataSiswa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExportDataSiswaActionPerformed(evt);
            }
        });

        btImportDataSiswa.setText("Import");
        btImportDataSiswa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btImportDataSiswaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelDataSiswaLayout = new javax.swing.GroupLayout(panelDataSiswa);
        panelDataSiswa.setLayout(panelDataSiswaLayout);
        panelDataSiswaLayout.setHorizontalGroup(
            panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDataSiswaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDataSiswaLayout.createSequentialGroup()
                        .addComponent(btBatal, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 133, Short.MAX_VALUE)
                        .addComponent(btUbah, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btTambah))
                    .addGroup(panelDataSiswaLayout.createSequentialGroup()
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbNisSiswa)
                            .addComponent(lbNamaSiswa)
                            .addComponent(lbOrtuSiswa)
                            .addComponent(lbJekelSiswa)
                            .addComponent(lbKelasSiswa)
                            .addComponent(lbTingkatanSiswa)
                            .addComponent(lbAlamatSiswa)
                            .addComponent(lbAlamatOrtuSiswa)
                            .addComponent(lbHpSiswa))
                        .addGap(43, 43, 43)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(scAlamatOrtuSiswa, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addComponent(txOrtuSiswa, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(cbJekelSiswa, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(scAlamatSiswa)
                                .addComponent(txNamaSiswa)
                                .addComponent(txNisSiswa, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
                            .addComponent(cbTingkatanSiswa, 0, 214, Short.MAX_VALUE)
                            .addComponent(cbKelasSiswa, 0, 214, Short.MAX_VALUE)
                            .addComponent(txHpSiswa, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(scDataSiswa, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
                    .addGroup(panelDataSiswaLayout.createSequentialGroup()
                        .addComponent(lbTotalDataSiswa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btExportDataSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btImportDataSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 150, Short.MAX_VALUE)
                        .addComponent(txCariDataSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panelDataSiswaLayout.setVerticalGroup(
            panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDataSiswaLayout.createSequentialGroup()
                .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNisSiswa)
                    .addComponent(txNisSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbTotalDataSiswa)
                    .addComponent(btExportDataSiswa)
                    .addComponent(txCariDataSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btImportDataSiswa))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelDataSiswaLayout.createSequentialGroup()
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbNamaSiswa)
                            .addComponent(txNamaSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(scAlamatSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbAlamatSiswa))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbJekelSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbJekelSiswa))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbTingkatanSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbTingkatanSiswa))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbKelasSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbKelasSiswa))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbOrtuSiswa)
                            .addComponent(txOrtuSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbAlamatOrtuSiswa)
                            .addComponent(scAlamatOrtuSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbHpSiswa)
                            .addComponent(txHpSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSiswaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btTambah)
                            .addComponent(btUbah)
                            .addComponent(btBatal)))
                    .addComponent(scDataSiswa, 0, 0, Short.MAX_VALUE))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        panelDataSPP.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Input Master Pembayaran", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lbJenisSPP.setText("Jenis Pembayaran:");

        cbJenisSPP.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Pilih Salah Satu-" }));

        lbBiayaSPP.setText("Biaya:");

        lbDicicilSPP.setText("Bisa Dicicil:");

        btBatalSPP.setText("Baru");
        btBatalSPP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBatalSPPActionPerformed(evt);
            }
        });

        btBayarSPP.setText("Tambah");
        btBayarSPP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBayarSPPActionPerformed(evt);
            }
        });

        btUbahSPP.setText("Ubah");
        btUbahSPP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUbahSPPActionPerformed(evt);
            }
        });

        tbDataSPP.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbDataSPP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbDataSPPMouseClicked(evt);
            }
        });
        scrollDataSPP.setViewportView(tbDataSPP);

        lbTotalSPP.setText("Terdapat x data(s)");

        txCariSPP.setFont(new java.awt.Font("Tahoma", 2, 11));
        txCariSPP.setForeground(java.awt.Color.gray);
        txCariSPP.setText("Cari");
        txCariSPP.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txCariSPPKeyReleased(evt);
            }
        });

        lbTingkatanSPP.setText("Tingkatan:");

        cbTingkatanSPP.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Pilih Salah Satu-" }));

        lbIdSPP.setText("ID pembayaran:");

        txIdSPP.setEditable(false);
        txIdSPP.setText("1");

        lbPembayaran.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/pembayaran.png"))); // NOI18N

        javax.swing.GroupLayout panelDataSPPLayout = new javax.swing.GroupLayout(panelDataSPP);
        panelDataSPP.setLayout(panelDataSPPLayout);
        panelDataSPPLayout.setHorizontalGroup(
            panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDataSPPLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDataSPPLayout.createSequentialGroup()
                        .addComponent(lbIdSPP)
                        .addGap(17, 17, 17)
                        .addComponent(txIdSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btBatalSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelDataSPPLayout.createSequentialGroup()
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbJenisSPP)
                            .addComponent(lbBiayaSPP)
                            .addComponent(lbDicicilSPP)
                            .addComponent(lbTingkatanSPP))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txBiayaSPP)
                            .addComponent(cbJenisSPP, 0, 218, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDataSPPLayout.createSequentialGroup()
                                .addComponent(btUbahSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btBayarSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(ckDicicilSPP)
                            .addComponent(cbTingkatanSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(lbPembayaran, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(scrollDataSPP, javax.swing.GroupLayout.DEFAULT_SIZE, 686, Short.MAX_VALUE)
                    .addGroup(panelDataSPPLayout.createSequentialGroup()
                        .addComponent(lbTotalSPP)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 453, Short.MAX_VALUE)
                        .addComponent(txCariSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panelDataSPPLayout.setVerticalGroup(
            panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDataSPPLayout.createSequentialGroup()
                .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbTotalSPP)
                    .addComponent(txCariSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbIdSPP)
                    .addComponent(txIdSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDataSPPLayout.createSequentialGroup()
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbTingkatanSPP)
                            .addComponent(cbTingkatanSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbJenisSPP)
                            .addComponent(cbJenisSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbBiayaSPP)
                            .addComponent(txBiayaSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lbDicicilSPP)
                            .addComponent(ckDicicilSPP))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDataSPPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btBatalSPP)
                            .addComponent(btBayarSPP)
                            .addComponent(btUbahSPP))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbPembayaran, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)
                        .addContainerGap())
                    .addComponent(scrollDataSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 395, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        panelPengaturan.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Pengaturan", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        tabPengaturan.setTabPlacement(javax.swing.JTabbedPane.LEFT);

        lbIp.setText("IP:");

        lbPort.setText("Port:");

        lbDbName.setText("Database Name:");

        lbUsername.setText("Username:");

        lbPassword.setText("Password:");

        btOkDb.setText("OK");
        btOkDb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOkDbActionPerformed(evt);
            }
        });

        btBatalDb.setText("Batal");
        btBatalDb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBatalDbActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelDatabaseLayout = new javax.swing.GroupLayout(panelDatabase);
        panelDatabase.setLayout(panelDatabaseLayout);
        panelDatabaseLayout.setHorizontalGroup(
            panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatabaseLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDatabaseLayout.createSequentialGroup()
                        .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbIp)
                            .addComponent(lbPort)
                            .addComponent(lbDbName)
                            .addComponent(lbUsername)
                            .addComponent(lbPassword))
                        .addGap(24, 24, 24)
                        .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                            .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txUsername)
                                .addComponent(txIp, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                                .addComponent(txPort, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                                .addComponent(txDbName)))
                        .addContainerGap(651, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDatabaseLayout.createSequentialGroup()
                        .addComponent(btBatalDb, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btOkDb, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        panelDatabaseLayout.setVerticalGroup(
            panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatabaseLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbIp)
                    .addComponent(txIp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbPort)
                    .addComponent(txPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDbName)
                    .addComponent(txDbName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbUsername)
                    .addComponent(txUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbPassword)
                    .addComponent(txPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 218, Short.MAX_VALUE)
                .addGroup(panelDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btOkDb)
                    .addComponent(btBatalDb))
                .addContainerGap())
        );

        tabPengaturan.addTab("Database", panelDatabase);

        javax.swing.GroupLayout panelPengaturanLayout = new javax.swing.GroupLayout(panelPengaturan);
        panelPengaturan.setLayout(panelPengaturanLayout);
        panelPengaturanLayout.setHorizontalGroup(
            panelPengaturanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPengaturanLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabPengaturan, javax.swing.GroupLayout.DEFAULT_SIZE, 1005, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelPengaturanLayout.setVerticalGroup(
            panelPengaturanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPengaturanLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabPengaturan, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(buttonTransaksi)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonMaster, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 691, Short.MAX_VALUE)
                .addComponent(buttonPengaturan)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonHelp)
                .addGap(18, 18, 18))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelUtama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelTransaksiSPP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelDataSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(62, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelDataSPP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelPengaturan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(buttonMaster, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                        .addComponent(buttonTransaksi, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(buttonHelp, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                        .addComponent(buttonPengaturan, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelUtama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(65, Short.MAX_VALUE)
                    .addComponent(panelTransaksiSPP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(51, Short.MAX_VALUE)
                    .addComponent(panelDataSiswa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(51, Short.MAX_VALUE)
                    .addComponent(panelDataSPP, javax.swing.GroupLayout.PREFERRED_SIZE, 446, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(51, Short.MAX_VALUE)
                    .addComponent(panelPengaturan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelDataSPP, panelDataSiswa, panelPengaturan, panelUtama});

        panelDataSPP.getAccessibleContext().setAccessibleName("Input Data Detail Pembayaran");

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1071)/2, (screenSize.height-546)/2, 1071, 546);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonTransaksiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTransaksiActionPerformed
        popupMaster.setVisible(false);
        popupTransaksi.setLocation(buttonTransaksi.getLocationOnScreen().x, buttonTransaksi.getLocationOnScreen().y+buttonTransaksi.getSize().height);
        popupTransaksi.setVisible(true);
    }//GEN-LAST:event_buttonTransaksiActionPerformed

    private void itemSPPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemSPPActionPerformed
        hideAllPanel();
        panelTransaksiSPP.setVisible(true);
        hideAllPopUp();
    }//GEN-LAST:event_itemSPPActionPerformed

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        hideAllPopUp();
    }//GEN-LAST:event_formMouseClicked

    private void itemDataSiswaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemDataSiswaActionPerformed
        hideAllPanel();
        panelDataSiswa.setVisible(true);
        hideAllPopUp();
    }//GEN-LAST:event_itemDataSiswaActionPerformed

    private void buttonMasterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMasterActionPerformed
        popupTransaksi.setVisible(false);
        popupMaster.setLocation(buttonMaster.getLocationOnScreen().x, buttonMaster.getLocationOnScreen().y+buttonMaster.getSize().height);
        popupMaster.setVisible(true);
    }//GEN-LAST:event_buttonMasterActionPerformed

    private void itemDataPembayaranActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemDataPembayaranActionPerformed
        hideAllPanel();
        panelDataSPP.setVisible(true);
        hideAllPopUp();
    }//GEN-LAST:event_itemDataPembayaranActionPerformed

    private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged
        hideAllPopUp();
    }//GEN-LAST:event_formWindowStateChanged

    private void buttonPengaturanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPengaturanActionPerformed
        hideAllPanel();
        panelPengaturan.setVisible(true);
        hideAllPopUp();
    }//GEN-LAST:event_buttonPengaturanActionPerformed

    private void buttonHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHelpActionPerformed
        hideAllPopUp();
        new About().setVisible(true);
    }//GEN-LAST:event_buttonHelpActionPerformed

    private void btBayarSPPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBayarSPPActionPerformed
        if (btBayarSPP.getText().toLowerCase().equals("tambah")) {
            if (cbTingkatanSPP.getSelectedIndex() == 0) {
                JOptionPane.showMessageDialog(null, "Tolong pilih tingkatan.");
                cbTingkatanSPP.requestFocus();
            } else if (cbJenisSPP.getSelectedIndex() == 0) {
                JOptionPane.showMessageDialog(null, "Tolong pilih jenis pembayaran.");
                cbJenisSPP.requestFocus();
            } else if (Validation.isEmpty(txBiayaSPP, "")) {
                JOptionPane.showMessageDialog(null, "Tolong inputkan biaya pembayaran.");
                txBiayaSPP.requestFocus();
            } else {
                SPP spp = new SPP();
                try {
                    byte cicil = 0;
                    if (ckDicicilSPP.isSelected())
                        cicil = 1;
                    spp.getTable().insert(new String[]{null, (String) cbTingkatanSPP.getSelectedItem(), 
                    (String) cbJenisSPP.getSelectedItem(), txBiayaSPP.getText(), String.valueOf(cicil)});
                    refreshTable();
                    refreshField(MASTER_PEMBAYARAN);
                    refreshId();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                } catch (ClassNotFoundException ex) {
                    ex.printStackTrace();
                }
            }
        } else {
            SPP spp = new SPP();
            try {
                spp.getTable().delete(txIdSPP.getText());
                refreshTable();
                refreshField(MASTER_PEMBAYARAN);
                refreshId();
                hideEdit();
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
        }
    }//GEN-LAST:event_btBayarSPPActionPerformed

    private void btUbahSPPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUbahSPPActionPerformed
        if (cbTingkatanSPP.getSelectedIndex() == 0) {
            JOptionPane.showMessageDialog(null, "Tolong pilih tingkatan.");
            cbTingkatanSPP.requestFocus();
        } else if (cbJenisSPP.getSelectedIndex() == 0) {
            JOptionPane.showMessageDialog(null, "Tolong pilih jenis pembayaran.");
            cbJenisSPP.requestFocus();
        } else if (Validation.isEmpty(txBiayaSPP, "")) {
            JOptionPane.showMessageDialog(null, "Tolong inputkan biaya pembayaran.");
            txBiayaSPP.requestFocus();
        } else {
            SPP spp = new SPP();
            try {
                byte cicil = 0;
                if (ckDicicilSPP.isSelected())
                    cicil = 1;
                spp.getTable().update(new String[]{(String) cbTingkatanSPP.getSelectedItem(), 
                (String) cbJenisSPP.getSelectedItem(), txBiayaSPP.getText(), String.valueOf(cicil)},
                txIdSPP.getText());
                refreshTable();
                refreshField(MASTER_PEMBAYARAN);
                refreshId();
                hideEdit();
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
        }
    }//GEN-LAST:event_btUbahSPPActionPerformed

    private void tbDataSPPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDataSPPMouseClicked
        txIdSPP.setText((String) tbDataSPP.getValueAt(tbDataSPP.getSelectedRow(), 0));
        cbTingkatanSPP.setSelectedItem((String) tbDataSPP.getValueAt(tbDataSPP.getSelectedRow(), 1));
        cbJenisSPP.setSelectedItem((String) tbDataSPP.getValueAt(tbDataSPP.getSelectedRow(), 2));
        txBiayaSPP.setText((String) tbDataSPP.getValueAt(tbDataSPP.getSelectedRow(), 3));
        int cicil = Integer.valueOf((String) tbDataSPP.getValueAt(tbDataSPP.getSelectedRow(), 4));
        if (cicil == 1)
            ckDicicilSPP.setSelected(true);
        else
            ckDicicilSPP.setSelected(false);
        showEdit();
    }//GEN-LAST:event_tbDataSPPMouseClicked

    private void btBatalSPPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBatalSPPActionPerformed
        refreshField(MASTER_PEMBAYARAN);
        refreshId();
        hideEdit();
    }//GEN-LAST:event_btBatalSPPActionPerformed

    private void btBatalDbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBatalDbActionPerformed
        showHome();
    }//GEN-LAST:event_btBatalDbActionPerformed

    private void btOkDbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOkDbActionPerformed
        Database.setIp(txIp.getText());
        Database.setPort(txPort.getText());
        Database.setDbName(txDbName.getText());
        Database.setUser(txUsername.getText());
        Database.setPass(txPassword.getText());
        DatabaseConfiguration dc = new DatabaseConfiguration();
        try {
            dc.generate();
        } catch (Exception e) {
            e.printStackTrace();
        }
        showHome();
        refreshTable();
    }//GEN-LAST:event_btOkDbActionPerformed

    private void txNisSppKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txNisSppKeyReleased
        if (txNisSpp.getText().length() > 0) {
            Siswa s = new Siswa();
            SPP p = new SPP();
            try {
                ResultSet rs = s.getTable().select(new Where("nis_siswa = "+txNisSpp.getText()));
                rs.next();
                labelNamaValueSpp.setText(rs.getString("nama_siswa"));
                labelAlamatValueSpp.setText(rs.getString("alamat_siswa"));
                labelJenisKelaminValue.setText(rs.getString("jekel_siswa"));
                labelKelasValueSpp.setText(rs.getString("kelas_siswa"));
                labelTingkatanValueSpp.setText(rs.getString("tingkatan_siswa"));
                tbTagihan.setModel(new TableModel(p.getField(), p.getTable().select(new Where("tingkat_spp = '"+rs.getString("tingkatan_siswa") +"'"))));
                //ResultSet rs2 = p.getTable().select(new Where("tingkat_spp = '"+rs.getString("tingkatan_siswa")+"'"));
                /*for (byte i=0; i<tbTagihan.getRowCount(); i++)
                    comboJenisTagihanSpp.addItem(rs2.getString("jenis_spp"));*/
            } catch (Exception e) {
                labelNamaValueSpp.setText("-");
                labelAlamatValueSpp.setText("-");
                labelJenisKelaminValue.setText("-");
                labelKelasValueSpp.setText("-");
                labelTingkatanValueSpp.setText("-");
                tbTagihan.setModel(new DefaultTableModel());
            }
        }
    }//GEN-LAST:event_txNisSppKeyReleased

    private void txCariSPPKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txCariSPPKeyReleased
        SPP spp = new SPP();
        try {
            tbDataSPP.setModel(new TableModel(spp.getField(), spp.getTable().search(txCariSPP.getText())));
            lbTotalSPP.setText("Terdapat "+tbDataSPP.getRowCount()+" data pembayaran.");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_txCariSPPKeyReleased

    private void btExportDataSiswaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExportDataSiswaActionPerformed
        FileFilter xls = new FileNameExtensionFilter("XLS Files (*.xls)", "xls");
        JFileChooser fc = new JFileChooser();
        fc.setAcceptAllFileFilterUsed(false);
        fc.addChoosableFileFilter(xls);
        fc.showSaveDialog(null);
        String ext = "";
        if (!Util.findexts(fc.getSelectedFile().toString()).equals("xls"))
            ext = ".xls";
        if (fc.getSelectedFile().getAbsolutePath() != null) {
            try {
                Siswa siswa = new Siswa();
                HSSFWorkbook woorkbook = new HSSFWorkbook();
                FileOutputStream out = new FileOutputStream(fc.getSelectedFile().getAbsolutePath()+ext);
                Sheet dataSiswa = woorkbook.createSheet("Data Siswa");
                
                //Nulis Judul Excel
                Row top1 = dataSiswa.createRow(0) ;
                Row top2 = dataSiswa.createRow(1) ;
                top1.setHeight((short) 500);
                Cell tcell = top1.createCell(0);
                tcell.setCellValue("Data Siswa");
                Font tFont = woorkbook.createFont();
                CellStyle tCs = woorkbook.createCellStyle();
                tCs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                tFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
                tFont.setFontHeight((short) 100);
                tcell.setCellStyle(tCs);
                dataSiswa.addMergedRegion(new CellRangeAddress(0, 0, 0, tbDataSiswa.getColumnCount()-1));
                
                //Nulis Judul
                Row title = dataSiswa.createRow(2);
                for (byte k=0; k<siswa.getField().length; k++) {
                    Cell cell = title.createCell(k);
                    cell.setCellValue(TextUtil.makeTitle(siswa.getField()[k]));
                    CellStyle cs = woorkbook.createCellStyle();
                    cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cs.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
                    cs.setBorderBottom(CellStyle.BORDER_THIN);
                    cs.setBottomBorderColor(IndexedColors.BLACK.getIndex());
                    cs.setBorderLeft(CellStyle.BORDER_THIN);
                    cs.setLeftBorderColor(IndexedColors.GREEN.getIndex());
                    cs.setBorderRight(CellStyle.BORDER_THIN);
                    cs.setRightBorderColor(IndexedColors.BLUE.getIndex());
                    cs.setBorderTop(CellStyle.BORDER_THIN);
                    cs.setTopBorderColor(IndexedColors.BLACK.getIndex());
                    Font font = woorkbook.createFont();
                    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
                    cs.setFont(font);
                    cell.setCellStyle(cs);
                    dataSiswa.autoSizeColumn(k);
                }
                
                //Nulis Nilai
                for (byte i=3; i<tbDataSiswa.getRowCount()+3; i++) {
                    Row row = dataSiswa.createRow(i);
                    for (byte j=0; j<tbDataSiswa.getColumnCount(); j++) {
                        Cell cell = row.createCell(j);
                        cell.setCellValue((String) tbDataSiswa.getValueAt(i-3, j));
                        CellStyle cs = woorkbook.createCellStyle();
                        cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                        cs.setBorderBottom(CellStyle.BORDER_THIN);
                        cs.setBottomBorderColor(IndexedColors.BLACK.getIndex());
                        cs.setBorderLeft(CellStyle.BORDER_THIN);
                        cs.setLeftBorderColor(IndexedColors.GREEN.getIndex());
                        cs.setBorderRight(CellStyle.BORDER_THIN);
                        cs.setRightBorderColor(IndexedColors.BLUE.getIndex());
                        cs.setBorderTop(CellStyle.BORDER_THIN);
                        cs.setTopBorderColor(IndexedColors.BLACK.getIndex());
                        cell.setCellStyle(cs);
                        dataSiswa.autoSizeColumn(j);
                    }
                }
                dataSiswa.autoSizeColumn(0, false);
                woorkbook.write(out);
                out.close();
                JOptionPane.showMessageDialog(null, "Export successfully.");
            } catch (FileNotFoundException e) {
                JOptionPane.showMessageDialog(null, "Can't export your data. Please try again.");
            } catch (IOException e) {
                JOptionPane.showMessageDialog(null, "Can't export your data. Please try again.");
            }
        }
}//GEN-LAST:event_btExportDataSiswaActionPerformed

    private void txCariDataSiswaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txCariDataSiswaKeyReleased
        Siswa spp = new Siswa();
        try {
            tbDataSiswa.setModel(new TableModel(spp.getField(), spp.getTable().search(txCariDataSiswa.getText())));
            lbTotalDataSiswa.setText("Terdapat "+tbDataSiswa.getRowCount()+" siswa.");
        } catch (Exception e) {
            e.printStackTrace();
        }
}//GEN-LAST:event_txCariDataSiswaKeyReleased

    private void tbDataSiswaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDataSiswaMouseClicked
        txNisSiswa.setText((String) tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 0));
        txNamaSiswa.setText((String) tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 1));
        txAlamatSiswa.setText((String) tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 2));
        cbJekelSiswa.setSelectedItem(tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 3));
        cbTingkatanSiswa.setSelectedItem(tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 4));
        refreshCheckbox();
        cbKelasSiswa.setSelectedItem(tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 5));
        txOrtuSiswa.setText((String) tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 6));
        txAlamatOrtuSiswa.setText((String) tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 7));
        txHpSiswa.setText((String) tbDataSiswa.getValueAt(tbDataSiswa.getSelectedRow(), 8));
        btTambah.setText("Hapus");
        btUbah.setVisible(true);
}//GEN-LAST:event_tbDataSiswaMouseClicked

    private void btBatalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBatalActionPerformed
        btTambah.setText("Tambah");
        refreshField(MASTER_SISWA);
        btUbah.setVisible(false);
        tbDataSiswa.clearSelection();
}//GEN-LAST:event_btBatalActionPerformed

    private void btUbahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUbahActionPerformed
        if (Validation.isEmpty(txNisSiswa, "")) {
            JOptionPane.showMessageDialog(null, "Tolong inputkan NIS Siswa.");
            txNisSiswa.requestFocus();
        } else if (Validation.isEmpty(txNamaSiswa, "")) {
            JOptionPane.showMessageDialog(null, "Tolong inputkan Nama Siswa.");
            txNamaSiswa.requestFocus();
        } else if (Validation.isEmpty(txAlamatSiswa, "")) {
            JOptionPane.showMessageDialog(null, "Tolong inputkan Alamat Siswa.");
            txAlamatSiswa.requestFocus();
        } else if (Validation.isEmpty(cbJekelSiswa, 0)) {
            JOptionPane.showMessageDialog(null, "Tolong pilih Jenis Kelamin Siswa.");
            cbJekelSiswa.requestFocus();
        } else if (Validation.isEmpty(cbTingkatanSiswa, 0)) {
            JOptionPane.showMessageDialog(null, "Tolong pilih Tingkatan Siswa.");
            cbTingkatanSiswa.requestFocus();
        } else if (Validation.isEmpty(cbKelasSiswa, 0) && cbTingkatanSiswa.getSelectedIndex() != 1) {
            JOptionPane.showMessageDialog(null, "Tolong pilih Kelas Siswa.");
            cbKelasSiswa.requestFocus();
        } else if (Validation.isEmpty(txOrtuSiswa, "")) {
            JOptionPane.showMessageDialog(null, "Tolong inputkan Nama Orang Tua Siswa.");
            txOrtuSiswa.requestFocus();
        } else {
            try {
                Siswa siswa = new Siswa();
                String kelas = "";
                if (cbKelasSiswa.getSelectedIndex() != 0)
                    kelas = (String) cbKelasSiswa.getSelectedItem();
                siswa.getTable().update(new String[] {txNamaSiswa.getText(),
                txAlamatSiswa.getText(), (String) cbJekelSiswa.getSelectedItem(), (String) cbTingkatanSiswa.getSelectedItem(),
                kelas, txOrtuSiswa.getText(), txAlamatOrtuSiswa.getText(),
                txHpSiswa.getText()}, txNisSiswa.getText());
                refreshField(MASTER_SISWA);
                refreshTable();
                btTambah.setText("Tambah");
                btUbah.setVisible(false);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
}//GEN-LAST:event_btUbahActionPerformed

    private void btTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTambahActionPerformed
        if (btTambah.getText().equals("Tambah")) {
            if (Validation.isEmpty(txNisSiswa, "")) {
                JOptionPane.showMessageDialog(null, "Tolong inputkan NIS Siswa.");
                txNisSiswa.requestFocus();
            } else if (Validation.isEmpty(txNamaSiswa, "")) {
                JOptionPane.showMessageDialog(null, "Tolong inputkan Nama Siswa.");
                txNamaSiswa.requestFocus();
            } else if (Validation.isEmpty(txAlamatSiswa, "")) {
                JOptionPane.showMessageDialog(null, "Tolong inputkan Alamat Siswa.");
                txAlamatSiswa.requestFocus();
            } else if (Validation.isEmpty(cbJekelSiswa, 0)) {
                JOptionPane.showMessageDialog(null, "Tolong pilih Jenis Kelamin Siswa.");
                cbJekelSiswa.requestFocus();
            } else if (Validation.isEmpty(cbTingkatanSiswa, 0)) {
                JOptionPane.showMessageDialog(null, "Tolong pilih Tingkatan Siswa.");
                cbTingkatanSiswa.requestFocus();
            } else if (Validation.isEmpty(cbKelasSiswa, 0) && cbTingkatanSiswa.getSelectedIndex() != 1) {
                JOptionPane.showMessageDialog(null, "Tolong pilih Kelas Siswa.");
                cbKelasSiswa.requestFocus();
            } else if (Validation.isEmpty(txOrtuSiswa, "")) {
                JOptionPane.showMessageDialog(null, "Tolong inputkan Nama Orang Tua Siswa.");
                txOrtuSiswa.requestFocus();
            } else {
                try {
                    Siswa siswa = new Siswa();
                    String kelas = "";
                    if (cbKelasSiswa.getSelectedIndex() != 0)
                        kelas = (String) cbKelasSiswa.getSelectedItem();
                    siswa.getTable().insert(new String[] {txNisSiswa.getText(), txNamaSiswa.getText(),
                    txAlamatSiswa.getText(), (String) cbJekelSiswa.getSelectedItem(), (String) cbTingkatanSiswa.getSelectedItem(),
                    kelas, txOrtuSiswa.getText(), txAlamatOrtuSiswa.getText(),
                    txHpSiswa.getText()});
                    refreshField(MASTER_SISWA);
                    refreshTable();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else {
            if (Validation.isEmpty(txNisSiswa, "")) {
                JOptionPane.showMessageDialog(null, "Tolong inputkan NIS Siswa.");
                txNisSiswa.requestFocus();
            } else {
                Siswa siswa = new Siswa();
                try {
                    siswa.getTable().delete(txNisSiswa.getText());
                    refreshField(MASTER_SISWA);
                    refreshTable();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
}//GEN-LAST:event_btTambahActionPerformed

    private void cbTingkatanSiswaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTingkatanSiswaActionPerformed
        refreshCheckbox();
}//GEN-LAST:event_cbTingkatanSiswaActionPerformed

    private void btImportDataSiswaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btImportDataSiswaActionPerformed
        FileFilter xls = new FileNameExtensionFilter("XLS Files (*.xls)", "xls");
        JFileChooser fc = new JFileChooser();
        fc.setAcceptAllFileFilterUsed(false);
        fc.addChoosableFileFilter(xls);
        fc.showOpenDialog(null);
        if (fc.getSelectedFile().getAbsolutePath() != null) {
            try {
                InputStream in = new FileInputStream(fc.getSelectedFile().getAbsolutePath());
                HSSFWorkbook workbook = new HSSFWorkbook(in);
                Sheet dataSiswa = workbook.getSheetAt(0);
                Siswa siswa = new Siswa();
                for (byte i=3; i<dataSiswa.getLastRowNum()+1; i++) {
                    Row row = dataSiswa.getRow(i);
                    String[] value = new String[tbDataSiswa.getColumnCount()];
                    for (byte j=0; j<tbDataSiswa.getColumnCount(); j++) {
                        value[j] = row.getCell(j).getStringCellValue();
                    }
                    siswa.getTable().insert(value);
                }
                JOptionPane.showMessageDialog(null, "Import successfully.");
                refreshTable();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Can't process your data. Please try again.");
            }
        }
    }//GEN-LAST:event_btImportDataSiswaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                Setting.setUseEncrypt(false);
                try {
                    if (new File("conf.ini").exists()) {
                        DatabaseConfiguration dc = new DatabaseConfiguration();
                        dc.assign();
                        new MainMenu().setVisible(true);
                    } else {
                        Wizard wizard = new Wizard(new MainMenu());
                        wizard.setVisible(true);
                        wizard.requestFocusInWindow();
                    }
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Can't starting SmartSPP.");
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btBatal;
    private javax.swing.JButton btBatalDb;
    private javax.swing.JButton btBatalSPP;
    private javax.swing.JButton btBatalSpp;
    private javax.swing.JButton btBayarSPP;
    private javax.swing.JButton btBayarSpp;
    private javax.swing.JButton btExportDataSiswa;
    private javax.swing.JButton btImportDataSiswa;
    private javax.swing.JButton btOkDb;
    private javax.swing.JButton btTambah;
    private javax.swing.JButton btUbah;
    private javax.swing.JButton btUbahSPP;
    private javax.swing.JButton btUbahSpp;
    private javax.swing.JButton buttonHelp;
    private javax.swing.JButton buttonMaster;
    private javax.swing.JButton buttonPengaturan;
    private javax.swing.JButton buttonTransaksi;
    private javax.swing.JComboBox cbJekelSiswa;
    private javax.swing.JComboBox cbJenisSPP;
    private javax.swing.JComboBox cbKelasSiswa;
    private javax.swing.JComboBox cbTingkatanSPP;
    private javax.swing.JComboBox cbTingkatanSiswa;
    private javax.swing.JCheckBox ckDicicilSPP;
    private javax.swing.JComboBox comboJenisTagihanSpp;
    private javax.swing.JMenuItem itemDataPembayaran;
    private javax.swing.JMenuItem itemDataSiswa;
    private javax.swing.JMenuItem itemSPP;
    private javax.swing.JLabel labelAlamatSpp;
    private javax.swing.JLabel labelAlamatValueSpp;
    private javax.swing.JLabel labelJenisKelamin;
    private javax.swing.JLabel labelJenisKelaminValue;
    private javax.swing.JLabel labelJenisTagihanSpp;
    private javax.swing.JLabel labelJumlahBayarSpp;
    private javax.swing.JLabel labelKelasSpp;
    private javax.swing.JLabel labelKelasValueSpp;
    private javax.swing.JLabel labelNamaSpp;
    private javax.swing.JLabel labelNamaValueSpp;
    private javax.swing.JLabel labelNisSpp;
    private javax.swing.JLabel labelSelamatDatang;
    private javax.swing.JLabel labelTagihanBelumBayar;
    private javax.swing.JLabel labelTingkatan;
    private javax.swing.JLabel labelTingkatanValueSpp;
    private javax.swing.JLabel labelTotal;
    private javax.swing.JLabel lbAlamatOrtuSiswa;
    private javax.swing.JLabel lbAlamatSiswa;
    private javax.swing.JLabel lbBiayaSPP;
    private javax.swing.JLabel lbDbName;
    private javax.swing.JLabel lbDicicilSPP;
    private javax.swing.JLabel lbHpSiswa;
    private javax.swing.JLabel lbIdSPP;
    private javax.swing.JLabel lbIp;
    private javax.swing.JLabel lbJekelSiswa;
    private javax.swing.JLabel lbJenisSPP;
    private javax.swing.JLabel lbKelasSiswa;
    private javax.swing.JLabel lbNamaSiswa;
    private javax.swing.JLabel lbNisSiswa;
    private javax.swing.JLabel lbOrtuSiswa;
    private javax.swing.JLabel lbPassword;
    private javax.swing.JLabel lbPembayaran;
    private javax.swing.JLabel lbPort;
    private javax.swing.JLabel lbTingkatanSPP;
    private javax.swing.JLabel lbTingkatanSiswa;
    private javax.swing.JLabel lbTotalDataSiswa;
    private javax.swing.JLabel lbTotalSPP;
    private javax.swing.JLabel lbUsername;
    private javax.swing.JPanel panelDataSPP;
    private javax.swing.JPanel panelDataSiswa;
    private javax.swing.JPanel panelDatabase;
    private javax.swing.JPanel panelPengaturan;
    private javax.swing.JPanel panelTransaksiSPP;
    private javax.swing.JPanel panelUtama;
    private javax.swing.JPopupMenu popupMaster;
    private javax.swing.JPopupMenu popupTransaksi;
    private javax.swing.JScrollPane scAlamatOrtuSiswa;
    private javax.swing.JScrollPane scAlamatSiswa;
    private javax.swing.JScrollPane scDataSiswa;
    private javax.swing.JScrollPane scrollData;
    private javax.swing.JScrollPane scrollDataSPP;
    private javax.swing.JScrollPane scrollTagihan;
    private javax.swing.JTabbedPane tabPengaturan;
    private javax.swing.JTable tabelData;
    private javax.swing.JTable tbDataSPP;
    private javax.swing.JTable tbDataSiswa;
    private javax.swing.JTable tbTagihan;
    private javax.swing.JTextField textCariTransaksiSPP;
    private javax.swing.JTextField textJumlahBayarSpp;
    private javax.swing.JTextArea txAlamatOrtuSiswa;
    private javax.swing.JTextArea txAlamatSiswa;
    private javax.swing.JTextField txBiayaSPP;
    private javax.swing.JTextField txCariDataSiswa;
    private javax.swing.JTextField txCariSPP;
    private javax.swing.JTextField txDbName;
    private javax.swing.JTextField txHpSiswa;
    private javax.swing.JTextField txIdSPP;
    private javax.swing.JTextField txIp;
    private javax.swing.JTextField txNamaSiswa;
    private javax.swing.JTextField txNisSiswa;
    private javax.swing.JTextField txNisSpp;
    private javax.swing.JTextField txOrtuSiswa;
    private javax.swing.JTextField txPassword;
    private javax.swing.JTextField txPort;
    private javax.swing.JTextField txUsername;
    // End of variables declaration//GEN-END:variables
}
